package com.model.dto.sys.LoginController;

import com.common.utils.Md5Utils;
import com.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Data
public class LoginDTO {
    /**包含邮箱，手机号，登录名 */
    @ApiModelProperty(value = "用户名不能为空，用户名长度限制为120",required = true)
    @NotNull(message = "用户名不能为空")
    @Size(min = 1, max = 120, message = "用户名长度限制为120")
    String username;

    @ApiModelProperty(value = "密码不能为空，密码长度限制为120",required = true)
    @NotNull(message = "密码不能为空")
    @Size( max = 120, message = "密码长度限制为120")
    String password;

    @ApiModelProperty(value = "滑块验证码返回的登录关键字",required = true)
    @Size( max = 50, message = "滑块验证码长度限制为50")
    String unlockLogin;

//    @Size(min = 0, max = 25, message = "终端设备不合法")
//    String os;
//
//    @Size(min = 0, max = 25, message = "版本号不合法")
//    String edition;

    public void setPassword(String password) {
        if(StringUtils.isNotEmpty(password)){
            password=Md5Utils.toUpperCase32(password);
        }
        this.password = password;
    }
}
